<?php //echo '<pre>';print_r($ctx->getTriggers['result']);exit;?>
<tal:block tal:repeat="users  getTriggers/result">
<?php $count = count($ctx->users['TriggersRelations']);
if($count>1)
{
	if(@$ctx->users['TriggersRelations'][0]['Groups'][0]['group_id'] != 0)
	{
		$profPic = '/Uploads/users/'.$ctx->users['photo'];
		$otherCount = ($count-1);
				foreach($ctx->users['TriggersRelations'] as $group)
				{
					$group_ids[]= $group['Groups'][0]['group_id'];
				}
				//$others =  'and '.$otherCount.' other group(s)';
				$group_id = array_unique($group_ids);
				$otherCount = count($group_id)-1;
				//echo '<pre>';print_r($group_id);exit;
				//$count = 0;
		$name = $ctx->users['TriggersRelations'][0]['Groups'][0]['name'];
		if($otherCount>0)
		$others =  'and '.$otherCount.' other group(s)';
		else $others="";
		//$count = 0;
	} 
	else
	{
		$profPic = '/Uploads/users/'.$ctx->users['photo'];
		$name = "public";
		$others = "";
	}
	$shareTpye = 'Shared';
	$shareIcon = 'SendIconSm.png';
	$shareAlt = "Sent";
}
	
else
	{

		$profPic = '/Uploads/users/'.$ctx->users['photo'];
		$name = $ctx->users['first_name'];
		$others = "";
		$shareIcon = 'ReceiveIconSm.png';
		$shareAlt = "Received";
	}
	if(count($ctx->users['TriggersRelations'][0]['MyFavorites'])>0)
	{
		$user_id = $ctx->users['TriggersRelations'][0]['MyFavorites']['owner_id'];
		$favorite_status = $ctx->users['TriggersRelations'][0]['MyFavorites']['status'];
		
		
	} else {
		$favorite_status = 'Inactive';
		$user_id = '';
	}
 ?>
<div class="Expr">
<?php if($ctx->users['TriggersRelations'][0]['read_status'] == 0) { $class="act"; } else { $class="nor"; } ?>
<div class="<?php echo $class;?>">
<div class="blkCont">
<p class="UserImg"><img src="<?php echo $profPic; ?>" height="45" width="45" alt="Tock" title="Tock"/></p>
<p class="Date"> <?php echo date('M d y',strtotime($ctx->users['added_date']));?></p>
</div>
<div class="blkCont">
<div class="wid240">
<p class="UName"><a href="javascript:void(0);" onclick="javascript:alert('Profile page is in progress');"><?php echo $name;?></a>&nbsp;<?php echo $others;?></p>
<p class="Title"><a href="/triggers/index/triggers-view/2/<?php echo base64_encode($ctx->getTriggers['currentPage']).'/'.base64_encode($ctx->users['id']);?>"><span tal:content="structure php: this.SubStrText(users['message'], 30)">Des Here</span></a></p>
<span><a class="UserShare" id="create" href="javascript:void(0);" onclick="shareTrigger(<?php echo $ctx->users['id'];?>)">Share</a></span>
<?php if($ctx->users['cnt']!='') { 
	$cnt = $ctx->users['cnt']; 
	} else {
	$cnt = 0;	
	}
?>
<span><a class="UserComment" id="create" href="javascript:void(0);">Comments(<?php echo $cnt;?>)</a></span>
</div>
</div>
<div class="blkContRt">
<?php $count = count($ctx->users['TriggersRelations']);
if($count>1)
{
	
	$id=$ctx->users['id'];
	$type="trigger_id";
}
else
{
	$id=$ctx->users['TriggersRelations'][0]['id'];
	$type="relation_id";
}
//echo $user_id.'--'.$favorite_status;
 ?>
 <?php if($shareIcon != '') { ?>
  <span><img src="/images/<?php echo $shareIcon;?>" alt="<?php echo $shareAlt;?>" title="<?php echo $shareAlt;?>" /></span>
 <?php } ?>
 <?php if($favorite_status=="Active"&& $user_id==$_SESSION["sess_userid"]){?>
<a href="javascript:void(0);" onclick="changeStatusFavorite(<?php echo $ctx->users['id'];?>,'Inactive')"><img src="/images/FavorIconAct.png" alt="Favorite" title="Favorite" /></a>
<? } else {?>
<a href="javascript:void(0);" onclick="changeStatusFavorite(<?php echo $ctx->users['id'];?>,'Active')"><img src="/images/FavorIconNor.png" alt="Favorite" title="Favorite" /></a>
<? } ?>
<span><a href="javascript:void(0);" onclick="deleteTrigger(<?php echo $id;?>,'<?php echo $type;?>');"><img src="/images/CloseIcon.png" alt="Close" border="0" class="img_inline" title="Delete"/></a></span>
</div>
<div class="clear"></div>
</div>
</div>
</tal:block>


